{m:include "member","header"}
<script type="text/javascript" src="{STATIC_URL}js/yzm_common.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/lang/zh-cn/zh-cn.js"></script>
<div class="yzm_member_container main">
    {m:include "member","left"}
    <div class="main_right">
        <div class="tit">
            <h3>稿件编辑</h3>
        </div>
        <div class="main_cont">
            <form method="post" action="" onsubmit="return chcekall(this)">
                <input type="hidden" name="id" value="{$id}">
                <table>
                    <tr>
                        <td width="70">栏目：</td>
                        <td>{get_catname($data['catid'])}<input type="hidden" name="catid" value="{$data['catid']}"></td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>标题：</td>
                        <td><input type="text" name="title" value="{$data['title']}" class="input w370"></td>
                    </tr>
                    <tr>
                        <td>关键字：</td>
                        <td><input type="text" name="keywords" value="{$data['keywords']}" class="input w370"></td>
                    </tr>
                    <tr>
                        <td>缩略图：</td>
                        <td>{form::image('thumb',$data['thumb'])}
                    </tr>
                    <tr>
                        <td>摘要：</td>
                        <td><textarea name="description" class="textarea" style="width:690px;">{$data['description']}</textarea></td>
                    </tr>
                    {loop $fieldstr $val}
                    <tr>
                        <td>{$val[field]}：</td>
                        <td>{$val[form]}</td>
                    </tr>
                    {/loop}
                    <tr style="height:20px;">
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><span class="required">*</span>内容：</td>
                        <td>{form::editor_mini('content',$data['content'])}</td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" name="dosubmit" class="submit" value="提交"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
	  function chcekall(obj){
	  	  if(obj.title.value==''){
            layer.msg("标题不能为空!", {icon:2});
            return false;
          }
			
          //form必填字段的验证
          {loop $field_check $k=>$v}
                {if $v['isrequired'] && !in_array($v['fieldtype'], array('images','attachments','checkbox','editor','editor_mini'))}
                if(obj.{$k}.value==''){
                    layer.msg("{$v[errortips]}", {icon:2});
                    return false;
                }
                {/if}       
          {/loop}

		  if(UE.getEditor('content').getContent()==''){
				layer.msg("内容不能为空!", {icon:2});
				return false;
		  }

          layer.msg('正在发布中...', {icon:16, shade:0.21, time:false});
          $.ajax({
              type: "POST",
              url: "{U('edit_through')}", 
              data: $(obj).serialize(),
              dataType: "json", 
              success: function (msg) {
                  if(msg.status == 1){
                      layer.msg(msg.message, {icon:1, time:2000}, function(){
                          location.href = msg.url;
                      });
                  }else{
                      layer.msg(msg.message, {icon:2});
                  }
              }
          })       
          return false;
	  }
</script>
{m:include "member","footer"}